#include <stdio.h>

void selection_sort(int *my_array, int size);
int main(int argc, char const *argv[]){
    int my_array[10] = {1, 9, 45, 7, 15, -5, 2, 74, -27, 10};
    int my_array_length = sizeof(my_array)/sizeof(my_array[0]);
    selection_sort(my_array, my_array_length);
    for (int i = 0; i < my_array_length; i++)
        printf("%d ", my_array[i]);
    printf("\n");
    return 0;
}

void selection_sort(int *my_array, int size){
    int temp, smallest;
    int smallest_index;
    for (int i = 0; i < size; i++){
        smallest = my_array[i];
        smallest_index = i;
        for (int j = i; j < size; j++){
            if(my_array[j] < smallest){
                smallest = my_array[j];
                smallest_index = j;
            }
        }
        temp = my_array[i];
        my_array[i] = smallest;
        my_array[smallest_index] = temp;
    }
}
